import { createSlice } from "@reduxjs/toolkit";
const userSlice = createSlice({
  name: "user",
  initialState: {
    accessToken: "",
    //用户信息
    userInfo: {
      username: "",
      avatar: "",
    },
  },
  reducers: {
    localUserInfo(state, action) {
      // console.log(action.payload,'222222')
      state.accessToken = action.payload.accessToken;
      state.userInfo = action.payload.userInfo;
    },
    clearUserInfo(state) {
      state.accessToken = "";
      state.userInfo = {};
    },
  },
});
export default userSlice.reducer;
export const { localUserInfo, clearUserInfo } = userSlice.actions;
